Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

polygoat

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

polygoat

Make JavaScript functions that support both promise and callback styles.

  • 1.1.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
770
decreased by-15.85%
Maintainers
1
Weekly downloads
 
Created
Source

polygoat

Build Status js-standard-style

logo

polygoat is a tool to make functions support both callback and promise style.

  • very small, < 30 lines of code
  • no promise support/polyfill required
  • simple, hack-free
  • Node.js and browsers
  • fast, see benchmark

Getting started

npm install polygoat


var pg = require('polygoat');

or

<script src="node_modules/polygoat/index.js"></script>
var pg = window.polygoat

Usage

// wrap an asynchronous function with polygoat
function hybridFunction (path, callback) {
  return pg(function (done) {
    fs.readdir(path, done)
  }, callback)
}

// hybridFunction can be used with promise style
hybridFunction('/').then(console.log)

// or callback style
hybridFunction('/', console.log)

// you can also pass the Promise implementation of your choice
var bluebird = require('bluebird')

function hybridFunction (path, callback) {
  return pg(function (done) {
    fs.readdir(path, done)
  }, callback, bluebird)
}

hybridFunction() instanceof bluebird // true

Example

See example.js

Benchmark

See benchmark

Test

npm install standard
npm test

Goat icon by Agne Alesiute from the Noun Project

Keywords

FAQs

Package last updated on 17 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc